package android.project;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.TextView;

public class ResultProjectActivity extends Activity {

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result);
        Intent intent = getIntent();
        float city1Data;
        float city2Data;
        float city3Data;
        float city4Data;
        String city1Name;
        String city2Name;
        String city3Name;
        String city4Name;
        String googleChartURL = "http://chart.apis.google.com/chart?";
        
        city1Data = intent.getExtras().getFloat("RatingBarseoul");
        city2Data = intent.getExtras().getFloat("RatingBarbusan");
        city3Data = intent.getExtras().getFloat("RatingBardaejeon");
        city4Data = intent.getExtras().getFloat("RatingBargwangju");
        String chd = "cht=p3&chd=t:"+city1Data+","+city2Data+","+city3Data+","+city4Data+"&";
        
        city1Name = intent.getExtras().getString("seoul");
        city2Name = intent.getExtras().getString("busan");
        city3Name = intent.getExtras().getString("daejeon");
        city4Name = intent.getExtras().getString("gwangju");
        String chs = "chs=250x100&chl="+city1Name+"|"+city2Name+"|"+city3Name+"|"+city4Name;
        
        String chartOpenAPI = googleChartURL + chd + chs;
        TextView TxtResult = (TextView)findViewById(R.id.result);
        TxtResult.setText(city1Name+""+(int)city1Data+" "+city2Name+""+(int)city2Data+" "+city3Name+""+(int)city3Data+" "+city4Name+""+(int)city4Data);
        
        final WebView wv = (WebView) findViewById(R.id.webView01);
        wv.loadUrl(chartOpenAPI);
        
//        try {
//        	URL url = new URL(chartOpenAPI);
//        	InputStream is = url.openStream();
//        	Drawable drawable = new BitmapDrawable(BitmapFactory.decodeStream(is));
//        	
//        	ImageView imageView = (ImageView) findViewById(R.id.imageView01);
//        	imageView.setImageDrawable(drawable);
//        	
//        } catch (Exception e) {
//        	Log.e("Net","Error in network call", e);
//        }
   }
}
